/*
 * @lc app=leetcode.cn id=1995 lang=typescript
 *
 * [1995] 统计特殊四元组
 */

// @lc code=start
function countQuadruplets(nums: number[]): number {
    let n = nums.length;
    let ans = 0;
    for (let a = 0; a < n; ++a) {
        for (let b = a + 1; b < n; ++b) {
            for (let c = b + 1; c < n; ++c) {
                for (let d = c + 1; d < n; ++d) {
                    if (nums[a] + nums[b] + nums[c] == nums[d]) {
                        ++ans;
                    }
                }
            }
        }
    }
    return ans;
}
// @lc code=end
